<!--
 * @Author: MrLee
 * @Date: 2024-08-24 08:55:14
 * @LastEditors: MrLee
 * @LastEditTime: 2024-08-24 11:40:26
 * @Description: 请填写简介
-->
<template>
  <custom-navbar title="看过我" :autoBack="true" leftIconColor="#303133" />
  <up-gap height="30rpx" />
  <view class="bg-#f6f7f8 px-22rpx">
    <view
      v-for="(item, index) in jobList"
      :key="index"
      class="job-item mb-32rpx bg-#fff px-40rpx py-24rpx shadow-[0px_6px_16px_0px_rgba(191,191,191,0.26)] rounded-[20rpx]"
      @click="jumpDetail(item.job_id)"
    >
      <view class="mb-14rpx flex items-center justify-between">
        <view class="text-left text-[32rpx] text-[#1d2129]">
          {{ item.job_name }}
        </view>
        <view
          class="text-[30rpx] text-[#1f50f2] font-semibold tracking-[-0.3rpx]"
        >
          {{item.salary_min}}k-{{item.salary_max}}k·{{item.salary_count}}薪
        </view>
      </view>
      <view
        class="mb-24rpx flex items-center text-left text-[26rpx] text-[#6e6d72] b-b b-b-#f6f7f8 b-b-solid pb-18rpx"
      >
        <view
          v-for="(itemTab, indexTab) in item.tabs"
          :key="indexTab"
          class="flex items-center justify-center"
        >
          <view :class="itemTab.ico" class="iconfont"></view>
          <view>{{ itemTab.label }}</view>
          <view
            v-if="indexTab != item.tabs.length - 1"
            class="mx-10rpx h-28rpx w-2rpx bg-#6e6d72"
          />
        </view>
      </view>
      <view class="flex items-center b-b b-b-#f6f7f8 b-b-solid pb-18rpx">
        <view class="relative mr-[20rpx]">
          <image
            src="https://yiliao.test03.qcw800.com/static/images/tab/user-01.png"
            class="block h-[20rpx] w-[20rpx] absolute rigth-0 bottom-0;"
            style="right: 0"
          />
          <image class="w-[72rpx] h-[72rpx]" :src="item.company_logo" />
        </view>
        <view class="flex flex-col justify-between">
          <view class="text-[28rpx] font-medium text-[#1d2129]">{{
            item.company_name
          }}</view>
          <view class="text-[26rpx] font-normal text-[#666666]">
          {{item.hr_name}}·{{item.hr_duty}}
          </view>
        </view>
      </view>
      <view class="flex items-center mt-26rpx pb-60rpx">
        <view class="text-[26rpx] font-normal text-[#666666] mr-10rpx"
          >职位详情</view
        >
        <view class="iconfont icon-youjiantou"></view>
      </view>
    </view>
    <up-gap height="60rpx" />
  </view>
</template>
<script setup lang="ts">
// import userCatch01 from "@/static/images/tab/user-catch-01.png";
import { userJobInteractionList } from '@/api/user';
// import home06 from '@/static/images/tab/home-06.png';
// import home10 from '@/static/images/tab/home-10.png';
const userCatch01 = "https://yiliao.test03.qcw800.com/static/images/tab/user-catch-01.png";
const home06 = 'https://yiliao.test03.qcw800.com/static/images/tab/home-06.png';
const home10 = 'https://yiliao.test03.qcw800.com/static/images/tab/home-10.png';

const jobList:any = ref();
//jobList = [...jobList, ...jobList, ...jobList, ...jobList];

async function getJobInterationList() {
  let result = await userJobInteractionList({me_look: 1});
  console.log('看过我 res list:::', result);
  //vue3传递result的值到子组件JobList中的属性jobList中
  let res = []
  for (let i = 0; i < result.list.length; i++) {
    const r = result.list[i]
    let rr = {
      job_name: r.job.name,
      job_id: r.job.id,
      salary_min: r.job.salary_min,
      salary_max: r.job.salary_max,
      salary_count: r.job.salary_count,
      province: r.job.province.name,
      city: r.job.city.name,
      job_nature: r.job.nature,
      qualifications: '',
      highlights: r.job.highlights,
      company_id: r.job.company.id,
      company_logo: r.job.company.url_logo,
      company_name: r.job.company.name,
      company_type: r.job.company.type == 1 ? '民营': r.job.company.type == 2 ? '国企' : '合资',
      company_listed: r.job.company.listed == 1 ? '未上市': '上市',
      like: r.like,
      like_img: r.like == 1 ? home06 : home10,
      tabs: <any>[],
      hr_avatar: r.job.user.avatar,
      hr_name: r.job.user.name,
      hr_duty: r.job.user.hr.duty.name,
      hr_id: r.job.user.id,
    }
    let qualifications = ''
    for (let j = 0; j < r.job.qualifications.length; j++) {
      qualifications += r.job.qualifications[j] + ' '
    }
    rr.qualifications = qualifications
    rr.tabs = [
      {
        label: rr.province + '·' + rr.city,
        ico: "icon-a-zu121328_1"
      },
      {
        label: rr.job_nature,
        ico: "icon-a-zu121326_1"
      },
      {
        label: rr.qualifications,
        ico: "icon-a-zu121327_1"
      }
    ]
    res.push(rr)
  }
  jobList.value = res;
}

const jumpDetail = (position_id:number) => {
  uni.navigateTo({
      url: '/pages/common/position-detail/index?job_id='+position_id
    });
}

onLoad((query: any) => {
  //query.status   1看过我
  console.log('看过我回传status:::',query.status);
  if(query.status === '4'){
    getJobInterationList();
  }
});
</script>
